package org.cshoo.sys.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import org.cshoo.common.util.MessageUtil;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	
	import org.cshoo.sys.business.DictionaryDelegate;
	import org.cshoo.sys.event.AddDictionaryEvent;
	import org.cshoo.sys.model.vo.Dictionary;

	public class AddDictionaryCommand implements ICommand, IResponder
	{
		public function execute(event:CairngormEvent):void
		{
			var dictionary:Dictionary = (event as AddDictionaryEvent).dictionary;
			var dictionaryDelegate:DictionaryDelegate = new DictionaryDelegate(this);
			dictionaryDelegate.addDictionary(dictionary);
		}
		
		public function result(event:Object):void
		{
			if((event as ResultEvent).result as Boolean)
			{
				MessageUtil.showInfoMessage("字典数据保存成功");
			}
			else
				MessageUtil.showErrorMessage("字典数据保存失败");
		}
		
		public function fault(info:Object):void
		{
			MessageUtil.showErrorMessage("字典数据保存失败：\n" + info.toString());
		}
	}
}